FROM python:3.9

RUN sed -i -e 's#deb.debian.org#mirrors.aliyun.com#g' \
  -e 's#security.debian.org#mirrors.aliyun.com#g' /etc/apt/sources.list \
  && apt-get update && apt-get install nodejs npm -y && apt-get clean \
  && pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ \
  && pip install pip --upgrade \
  && pip install ipython jupyterlab backtrader==1.9.76.123 ipympl nodejs plotting pandas jupyterlab-language-pack-zh-CN \
  && jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter-matplotlib \
  && sed -i -e '39s#, warnings##' -e '39aimport warnings' /usr/local/lib/python3.9/site-packages/backtrader/plot/locator.py \
  && sed -i -e '127s#nbagg#module://ipympl.backend_nbagg#' /usr/local/lib/python3.9/site-packages/backtrader/plot/plot.py

RUN pip install baostock tushare empyrical pyfolio

ENV SHELL=/bin/bash
WORKDIR /src
EXPOSE 8888

CMD ["jupyter-lab", "--ip=*", "--port=8888", "--no-browser", "--allow-root"]

